import {
	defineStore
} from "pinia"

import {
	ref
} from "vue"

import {
	feedListApi,
	doctorListApi,
	followDoctorApi
} from "@/api/modules/doctor.js"


const useDoctorStore = defineStore("doctor", () => {

	const list = ref([])
	const feedListTotal = ref(0)

	const doctorList = ref([])
	const feedListApiAction = async (data) => {
		const res = await feedListApi(data)
		if (res.code !== 10000) return uni.utils.toast(res.message)
		list.value = res.data.rows
		feedListTotal.value = res.data.total
	}

	const doctorListApiAction = async (data) => {
		const res = await doctorListApi(data)
		if (res.code !== 10000) return uni.utils.toast(res.message)
		doctorList.value = res.data.rows
		console.log(res.data.rows);
	}
	const followDoctorApiAction = async (id, type) => {
		const res = await followDoctorApi(id, type)
		if (res.code !== 10000) return uni.utils.toast(res.message)
		console.log(res);
	}
	return {
		list,
		feedListTotal,
		doctorList,
		feedListApiAction,
		doctorListApiAction,
		followDoctorApiAction
	}
})

export default useDoctorStore